chdkfandomcom-20200222-history
UBASIC/Scripts: OMNI Intervalometer
OMNI Intervalometer :Written for/on: Powershot S3 IS - CHDK Build 87 (or higher) Required :Also works on: S2(?) other models need the ":vid" subroutine modified. :Version 1.6 - Updated 2007-06-10 c.e.(CHDK Build 119 remapped shutter-values.) This script includes a command that only works on S-series cameras, it will not work as-is on A-series cameras. See notes below the script on how to modify this for A-series or other cameras. This version includes a few features that should fit most any need that arises. First you can select if you want to shoot single Still-Frame photos, Videos, Both, or shoot a timed Burst event. You can set a delay in minutes and seconds to the first shot of your intervalometer sequence, the number of shots for the intervalometer sequence, as well as allowing you to flag a Yes or No "Endless" option to repeat the sequence endlessly until you interrupt it manually by pressing the shutter button. : Documentation/Help (save as a small "omnintrvl.txt" file to your /SCRIPTS/ folder) ---- This interval shooting script allows you to choose between photos, videos, both, or a high-speed burst interval. You can also set a delay until the first shot in your intervalometer sequence. You may also choose to repeat the sequence endlessly. Use the "Endless" repeat with caution! If that flag is set it repeats non-stop until you interrupt it by pressing the shutter-button. Word of Warning: If you are running off of an AC power-supply and going to set the endless-repeat flag do so at your own risk. You should not allow your camera to run for many hours or days as it can harm your camera! (Though I'm not sure why, other than that warning is in all the Canon manuals.) :Photo=0 : Records single-frames only. :Vid=1 : Records video for the time set in Video/Burst time settings. :P&V=2 : Records a full-size single-frame at the begining of each video event. :Burst=3 : Puts camera into Continuous shooting mode and holds the shutter button for the time set in Video/Burst time settings. Hint: if needing an endless intervalometer sequence of one shot per interval, it is easier to set number of shots to 1, turn on the "Endless" option, and then use the "Delay 1st Shot" as your time between shots -- instead of cranking up the number of shots to a very high number and using the "Interval" time settings. These intervalometer scripts that use the "shoot" command (as opposed to the 'click "shoot_full"' command) also set focus and exposure before each shot (if the camera is not in M'''anual mode). Unlike the camera's own built-in intervalometer where exposure and focus is set for just the first shot. This allows it to compensate for all the varying conditions that can take place over the course of many minutes and hours, far surpassing Canon's concept of a useful intervalometer. Note 1: The count-down timer for the "Delay to 1st Shot" phase won't display beyond the time you have set for your Power Saving / Display Off settings. On the S3 IS this is a maximum count-down display of 3 minutes. The script will continue running however. You just won't have a running tally of how long until the next intervalometer sequence or shot. UPDATE CHDK Build #144 and later has an option in Misc. features to "Disable LCD Off", if that is set to "Script" your countdown timer will work for the full duration while the script is running. Note 2: If using shutter speeds longer than 1 second, then the dark-frame subtraction time is now figured into the total interval cycle-time. Use the total cycle-time as just a good approximation, as camera overhead for many frames could add up to make the total a bit different than what this script calculates. UPDATE CHDK Build #144 and later has an option in the RAW Parameters to turn "Noise Reduction OFF", if this is set to off then there is no black-frame subtraction interrupt. The total cycle-time displayed will be in error, as that is computed for a black-frame subtraction too. The script will run perfectly fine but you can't depend on that total-time when using exposures longer than 1-second. This is, however, an excellent option when doing lightning photography or any application where long, but short-interruption shutter speeds are needed. Use the burst mode in this script with slow shutter-speeds (1-15 seconds) and you can have your shutter open up to 95% of the time. Greatly increasing your chances of capturing that unpredictable lightning bolt or meteor during a meteor-shower. Note 3: Due to needing a long delay in the :burst subroutine to make it work, there will be an extra 2.5 seconds of time added into your pause between events when using the Burst option. If needing more exact interval timings for burst shooting events, subtract at least that much time from your required interval spacings. OR if you wanted to manually engage your camera's high-speed "continuous" (burst) mode, you could edit that subtroutine so it's not doing it for you. Remove the 3 "click 'timer'" and the "sleep 2000" commands. Note 4: If you require speeds faster than 1 frame every 2 or 3 seconds, run this script with CHDK build 119. Subsequent builds of CHDK with all the newer (and worthwhile) features seems to have slowed this script down somewhat. Be sure to also turn off all CHDK OSD elements, and any automatic camera features such as auto-exposure, white-balance, and focus, for optimum single-shot frame-rates. ---- '''Script Code (save as "omnintrvl.bas" to your /SCRIPTS/ folder) rem Author ~Keoeeit~ rem S-Series cameras ONLY rem Use Endless mode with caution rem See documentation for important info @title OMNI Intervalometer @param a Photo=0 Vid=1 P&V=2 Burst=3 @default a 0 @param b Delay 1st Shot (Mins) @default b 0 @param c Delay 1st Shot (Secs) @default c 0 @param d Number of Shots/Vids/Burst @default d 5 @param e Interval (Minutes) @default e 0 @param f Interval (Seconds) @default f 0 @param g Interval (10th Seconds) @default g 5 @param h Video/Burst Minutes @default h 0 @param i Video/Burst Seconds @default i 0 @param j Endless? No=0 Yes=1 @default j 0 p=b*600+c*10 t=e*600+f*10+g v=h*600+i*10 if a<0 then a=0 if a>3 then a=3 if d<1 then d=5 if t<1 then t=1 if j<0 then j=0 if j>1 then j=1 if p<0 then p=0 if v<10 then v=10 if a=0 then v=0 u=t get_tv k if a=1 then k=-14 if a=2 then t=t+10*d if a=3 then t=t+25*d if k=-12 then t=t+330 if k=-11 then t=t+270 if k=-10 then t=t+210 if k=-9 then t=t+170 if k=-8 then t=t+130 if k=-7 then t=t+110 if k=-6 then t=t+90 if k=-5 then t=t+70 if k=-4 then t=t+60 if k=-3 then t=t+50 if k=-2 then t=t+40 if k=-1 then t=t+35 if k=0 then t=t+18 if k=1 then t=t+15 if k=2 then t=t+13 if k=3 then t=t+11 if k=4 then t=t+10 if k=5 then t=t+8 if k=6 then t=t+6 x=p+(v*d)+(t*(d-1)) print "1 Cycle Time:", x/600; "min", x%600/10; "sec" goto "interval" :interval if p>0 then gosub "pause" for n=1 to d print "Shot", n, "of", d if n>1 then sleep u*100 if a=0 then shoot if a=1 then gosub "vid" if a=2 then gosub "vid" if a=3 then gosub "burst" next n if j=1 then goto "interval" else end :pause r=(b*60)+c for m=1 to r q=r-m print "Intvl Begins:", q/60; "min", q%60; "sec" sleep 930 next m return :vid if a=2 then shoot if a=2 then sleep 1000 click "video" sleep v*100 click "video" return :burst click "timer" press "shoot_half" sleep 500 press "shoot_full" sleep v*100 release "shoot_full" release "shoot_half" sleep 2000 click "timer" click "timer" return I timed the :pause subroutine and tweaked the sleep to 930 milliseconds to be about as accurate as possible for that loop to span 1 second for the for/print/next execution time. This was calculated on an S3 IS, your camera's uBASIC speed may vary, tweak "sleep 930" accordingly if you need more precision. (Accuracy testing hint: put your camera's display-on time to 3 minutes, set the script's Delay 1st Shot for 4 minutes, see what count-down timer line it ends on just before the screen goes blank (don't jiggle the camera or it resets the display-on time). On my S3 IS the screen went blank just as it was to start counting the 4th minute.) I put the routine to engage video on a separate subroutine named ":vid" so it would be easier to modify this for other cameras. Other camera models (A-series), will have to modify this ":vid" subroutine completely, using the proper key-presses or modes and menus on their cameras. I looked at the code for another video intervalometer script, but it appears that on other cameras that you have to set your camera for video mode from a dial or something, as there are no commands in the script to engage video. If someone else would like to jump in and add a way to include video for them on this script to make it compatible to other cameras that would be great. Because you can test it, whereas I can't. In order to get around the camera's time requirements for going into and out of different modes when choosing to shoot both still-frame and video, I had to put in a full 1 second delay between the "shoot" and click "video" commands. I compensated for this delay in the overall "print 1 Cycle Time". p.s. I totally remapped all the variables from earlier versions, just to make this easier to follow for anyone that wants to tear it apart or make it better. Hey? Do I at least get an award for being the first to use up all 10 user-definable variables? :-) v1.4 Update: Okay, I think I got most of the bugs worked out of it. The problem was in trying to use the old original intervalometer script as my base to work from. I had to rewrite the main :interval routine to get it to accept all these options properly, as well as keep track of total cycle-times properly for all 3 shooting modes (photo-only, video, or photo+video). It appears to be doing everything as planned, if anyone notices some main snafu, please throw a note in the "talk" section. v1.5 Update: I added in a routine to engage high-speed burst mode. It is after-all titled "OMNI Intervalometer", I wouldn't want to get blamed for false advertising. :-) HEY!! I only gots 10 bytes of space left out of 2000 available! Is there REALLY a 2k script limit and is that 2000 or 2048 bytes? I had to pack together all kinds of stuff to get under 2000. :-) v1.6 Update: CHDK Build 119 had its shutter times remapped better so there are no gaps in the table. The script was tweaked accordingly. This script can still be used as-is on earlier builds, but the 1-Cycle Time reported will be in error, being 6 seconds longer than that displayed if using shutter speeds from 10 and 13 seconds, and 18 seconds shorter if using a 15 second shutter speed, Everything else will work just fine, it's just the Cycle-Time display will be off in those 3 instances. If you don't have access to CHDK Build 119 or later and want a more accurate display, then you can just edit these lines if k=-12 then t=t+330 if k=-11 then t=t+270 if k=-10 then t=t+210 back to: if k=-13 then t=t+330 if k=-12 then t=t+270 if k=-11 then t=t+210 In Allbest's builds this script will not work until you change the following line get_tv k into: get_user_tv_id k OMNI Intervalometer 3 :Written for/on: Powershot S3 IS - CHDK Allbest or JuciPhoX Builds Required. JuciPhoX build available at http://www.saunalahti.fi/nirsku/chdk/ :Also works on: S2?, S5?, The A, G, and SD/IXUS models would need the ":vid" subroutine modified. An updated version to work with the newer Allbest and JuciPhox builds of CHDK. This script requires that your build of CHDK recognizes the get_tv96 and get_raw_nr uBASIC commands. If you find those strings listed in your diskboot.bin file (view with any editor that allows seeing binary files, i.e. UltraEdit) then you can use this script. The only difference in this script is that it more accurately calculates the Total Time Per Cycle reported. It now detects if you have noise-reduction turned to Auto, Off, or On and adds in the approximate noise-reduction time needed for each cycle as the case may be. It also calculates the overall cycle time more accurately if using shutter speeds below 1 second. This is merely a cosmetic feature for the intervalometer "cycle time" that is printed to your viewfinder screen, as it does not actually change the functionality nor timing of the shots per cycle and the cycles themselves (from the previous version). I just thought that if it's going to report the cycle time, it should be closer to what is actually going to occur. Even so, these calculated times are just a close approximation due to various cameras' file-saving and processing overhead. A fudge-factor of 0.2 to 0.5 seconds or so was added in to account for slower cameras, slower SD cards, and NR processing during the longer shutter speeds. One caveat: While this script will account for shutter times whether you are using the camera's own settings or using the CHDK Override settings, it requires that you half-press the shutter once while NOT in mode before actually running the script in mode. This sets the get_tv96 variable that is read (by the script) for whatever shutter time is selected by any means. This was the only way available to detect the correct shutter time whether selected by CHDK Override or by the camera's own auto-modes. Using any of the other get_tv variables available would account for one but not the other, resulting in the wrong cycle times being calculated. rem Author ~Keoeeit~ @title OMNI Intervalometer 3 @param a Photo=0 Vid=1 P&V=2 Burst=3 @default a 0 @param b Delay 1st Shot (Mins) @default b 0 @param c Delay 1st Shot (Secs) @default c 0 @param d Number of Shots/Vids/Burst @default d 5 @param e Interval (Minutes) @default e 0 @param f Interval (Seconds) @default f 0 @param g Interval (10th Seconds) @default g 5 @param h Video/Burst Minutes @default h 0 @param i Video/Burst Seconds @default i 0 @param j Endless? No=0 Yes=1 @default j 0 p=b*600+c*10 t=e*600+f*10+g v=h*600+i*10 if a<0 then a=0 if a>3 then a=3 if d<1 then d=5 if t<1 then t=1 if j<0 then j=0 if j>1 then j=1 if p<0 then p=0 if v<10 then v=10 if a=0 then v=0 u=t k=get_tv96 if a=1 then k=1 if a=2 then t=t+10*d if a=3 then t=t+25*d if get_raw_nr = 1 then gosub "addtv" if get_raw_nr <> 1 then gosub "addnr" x=p+(v*d)+(t*(d-1)) print "1 Cycle Time:", x/600; "min", x%600/10; "sec" goto "interval" :interval if p>0 then gosub "pause" for n=1 to d print "Shot", n, "of", d if n>1 then sleep u*100 if a=0 then shoot if a=1 then gosub "vid" if a=2 then gosub "vid" if a=3 then gosub "burst" next n if j=1 then goto "interval" else end :pause r=(b*60)+c for m=1 to r q=r-m print "Intvl Begins:", q/60; "min", q%60; "sec" sleep 930 next m return :vid if a=2 then shoot if a=2 then sleep 1000 click "video" sleep v*100 click "video" return :burst click "timer" press "shoot_half" sleep 500 press "shoot_full" sleep v*100 release "shoot_full" release "shoot_half" sleep 2000 click "timer" click "timer" return :addtv if k=-576 then t=t+645 if k=-544 then t=t+513 if k=-512 then t=t+408 if k=-480 then t=t+325 if k=-448 then t=t+259 if k=-416 then t=t+205 if k=-384 then t=t+165 if k=-352 then t=t+132 if k=-320 then t=t+105 if k=-288 then t=t+85 if k=-256 then t=t+68 if k=-224 then t=t+55 if k=-192 then t=t+45 if k=-160 then t=t+35 if k=-128 then t=t+30 if k=-96 then t=t+25 if k=-64 then t=t+20 if k=-32 then t=t+17 return :addnr if k=-576 then t=t+1300 if k=-544 then t=t+1030 if k=-512 then t=t+820 if k=-480 then t=t+650 if k=-448 then t=t+520 if k=-416 then t=t+410 if k=-384 then t=t+330 if k=-352 then t=t+270 if k=-320 then t=t+210 if k=-288 then t=t+170 if k=-256 then t=t+130 if k=-224 then t=t+110 if k=-192 then t=t+90 if k=-160 then t=t+70 if k=-128 then t=t+60 if k=-96 then t=t+50 if k=-64 then t=t+40 if k=-32 then t=t+35 if k=0 then t=t+18 if k=32 then t=t+15 if k=64 then t=t+13 if k=96 then t=t+11 if k=128 then t=t+10 if k=160 then t=t+8 if k=192 then t=t+6 return OMNI Intervalometer Category:Intervalometer